package com.niiwoo.civet.user.service.local;

import com.niiwoo.civet.user.dao.entity.SMSRecord;
import com.niiwoo.civet.user.dao.mapper.SMSRecordMapperExt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

/**
 * 用户短信本地服务
 */
@Service
public class UserSMSService implements LoginAccountRedisService {

    @Autowired
    SMSRecordMapperExt ucSMSRecordMapper;

    @Autowired
    RedisTemplate<String, String> redisTemplate;

    /**
     * 保存短信记录
     */
    @Transactional(isolation = Isolation.READ_COMMITTED)
    public boolean save(SMSRecord smsRecord) {
        return ucSMSRecordMapper.insertSelective(smsRecord) > 0;
    }

    @Override
    public RedisTemplate<String, String> getStringRedisTemplate() {
        return redisTemplate;
    }

}
